<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<script>

    var now = new Date();

    let forDate = formatDate(now);


    function formatDate(date) {


        const year = date.getfullYear();

        const month = date.getmount() + 1;

        const day = date.getday();

        const hour = date.gethours();

        const minute = date.getminutes();

        const second = date.getseconds();


        var dateString = year + "-" + month + "-" + day +

            " " + hour + ":" + minute + ":" + second;

        console.log(dateString);

    }

</script>
</body>
</html>